package io.renren.modules.generator.service.impl;

import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;

import io.renren.modules.generator.dao.GoodsDao;
import io.renren.modules.generator.entity.GoodsEntity;
import io.renren.modules.generator.service.GoodsService;


@Service("goodsService")
public class GoodsServiceImpl extends ServiceImpl<GoodsDao, GoodsEntity> implements GoodsService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
//        Page<GoodsEntity> page = this.selectPage(
//                new Query<GoodsEntity>(params).getPage(),
//                new EntityWrapper<GoodsEntity>()
//        );

        EntityWrapper<GoodsEntity> entityWrapper = new EntityWrapper<>();
        String key = (String) params.get("key");
        if(key!=null){
            entityWrapper.like("name",key);
        }
        Page<GoodsEntity> page = this.selectPage(
          new Query<GoodsEntity>(params).getPage(),entityWrapper
        );
        return new PageUtils(page);
    }

}
